/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package neuron;

/**
 *
 * @author risto
 */
public class Coord {
    public double x,y,z,d;

    @Override
    public String toString() {
    	return String.format("<%.2f, %.2f, %.2f>", x, y, z);
    }
    
    public Coord(double x, double y, double z, double d) {
        this.x = x;
        this.y = y;
        this.z = z;
        this.d = d;
    }

    public Coord(String x, String y, String z, String d) {
        this(Double.parseDouble(x),
                Double.parseDouble(y),
                Double.parseDouble(z),
                Double.parseDouble(d)
                );
    }

    /**
     * Distance to another coordinate
     * @param b
     * @return
     */
    public double distanceTo(Coord b)
    {
        double dx = b.x - x;
        double dy = b.y - y;
        double dz = b.z - z;
        return Math.sqrt(dx*dx + dy*dy + dz*dz);
    }
    
    /**
     * Return 3D array of coordinates (** should this include d? **)
     * @return
     */
    public double[] asArray()
    {
    	return new double[] { x, y, z };
    }
}
